-
Notifications
You must be signed in to change notification settings - Fork 26
MCMC Sampling of partially-observed multivariate normal nodes #1612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Conversation
`partial_mvn` sampler, to have the code here for posterity.
|
So do we think the most common use case would be that |
|
@paciorek Please see the addition of the When one or more dimensions (from among the unobserved dimensions) of a partially-observed MVN node themselves have no data dependencies, then a @paciorek A second set of eyes would be appreciated. There might also be some efficiency improvements with the linear algebra within the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, @danielturek . I took a reasonably careful look though I didn't look too carefully at the tests. In addition to my line-specific comments (some of them niggly - sorry!):
- We should discuss whether to cache the pieces of the conditional mvn, in particular choleskies if we know that the covariance is fixed. We could leave this for a future improvement, though if you have momentum on all this, perhaps we do it now?
- I'd like us to check if partial_mvn_pp is correctly assigned, so how about we build the MCMC in some of the tests and check the internal sampler assignments?
- I'm not sure about whether we should hide this behind an option. Perhaps it's fine if we don't, though if we add the caching and are less certain about that, then maybe we should.
- Can we check
MCMCuseBarkerAsDefaultMVand use Barker instead of sampler_RW_block if it is on? - Also I think we should have a test that checks correctness of the partial_mvn_pp sampler in a basic case.
I'm happy to help with any of this if you like.
|
@paciorek Thanks for the careful review. Repeating the request from above, my first preference would be to make the I'd be happy to discuss strategies for "caching" the components of the covariance matrix. But I think it would have to be done with some thought and some caution. Even if the covariance node has no parent nodes (stochastic or otherwise), the contents of the node can still be modified (regardless if the value is provided by constants, data, or initial values). So I can imagine a few ways we might try to do this, for example: "If the covariance node has no parent nodes, then we have a indicator internal to the sampler (say This is a tricky one, unless you have some better ideas that I'm not imagining. In the case of assigning the @paciorek Yes, please go ahead and make / add any tests for any of the following:
|
|
Ok I pushed a commit that has the implementation of the Cholesky of Sigma22. I didn't run tests (though CI will of course) or check correctness yet. As far as Barker, yes, that's correct the model would need to have derivs built. But I don't think anything is different with using Barker here than in our default MCMC config if that Barker option is set. Regarding caching, I will comment on that in a moment below. I will try to work on some of the other things this afternoon as well. Or tomorrow. Unless Frederic indicates urgency in response to my email I am now planning that we include this in 1.4.1 and am thinking I will push this to CRAN on Tuesday. I will be out of town over the long weekend. |
|
Regarding caching, I think the case that we can safely use cached values is if the covariance is RHS-only. If it has no parent nodes it could still be being sampled in an MCMC (e.g., if it is Two other thoughts:
I guess if my reasoning about checking for RHS-only is correct, I propose we combine that with your sketch of using |
|
I'm working on some additional tests. @danielturek I don't understand the logic in "Values change at same rows for unobserved parts of partially observed node when multivariateNodesAsScalars = FALSE" test. Based on the model is uses the |
|
@paciorek That test predated the addition of the |
|
@paciorek I worked through the linear algebra. I imagine it's simple to you, but this was helpful for me, and it was nice to see especially how the |
|
Ok, so my new code had some issues with dimensions that I just fixed. Results are now the same as Daniel's implementation. I added some tests, but the one I still want to add is one to check correctness of the _pp samples. I'll do that tomorrow morning. I'll let you decide what to do about the 'moot' test. |
|
I think we stepped on each other's commits a bit, but I think everything is ok now. |
|
@paciorek |
Addresses NCT issue 296.
This PR adds support for MCMC sampling of partially-observed multivariate normal nodes. That is, multivariate-distributed nodes, where some of the dimensions are observed data, and some of the dimensions are unobserved (latent). The
partial_mvnsampler essentially operates by assigning univariate RW samplers to the (individual) unobserved dimensions of partially-observed (and therefore also partially-unobserved) MVN-distributed nodes.More specifically, several cases for sampling the unobserved dimensions are handled:
posterior_predictivesamplers.multivariateNodesAsScalars = TRUE, then all remaining unobserved dimensions are assigned univariateRWsamplers.multivariateNodesAsScalars = FALSE, then all remaining unobserved dimensions are assigned a single multivariateRW_block.A variety of test cases are also added.